package com.web.cms.pan.service;

import com.blue.jdbc.JdbcDataSource;
import com.blue.jdbc.Page;
import com.web.cms.pan.dao.OperatorLogDao;
import com.web.cms.pan.dao.UserInfoDao;
import com.web.cms.pan.model.OperatorLog;
import com.web.cms.pan.model.UserInfo;
import com.web.core.util.Const;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * 用户网盘信息业务层
 * 
 * @author 代码由 blue-code 框架生成
 * @since 1.0 2018年04月09日
 */
@Service("panUserInfoService")
@Transactional
@JdbcDataSource(Const.DS_CMS)
public class UserInfoService
{
	@Autowired
	private UserInfoDao userInfoDao;
	@Autowired
	private OperatorLogDao operatorLogDao;
	
	public UserInfoService()
	{
	}
	
	public UserInfo save(UserInfo userInfo)
	{
		if (userInfo.getId() == null)
		{
			userInfoDao.save(userInfo);
		}
		else
		{
			userInfoDao.update(userInfo);
		}
		UserInfo a = userInfoDao.get(userInfo.getId());
		return a;
	}
	
	public UserInfo get(Integer id)
	{
		UserInfo userInfo = userInfoDao.get(id);
		return userInfo;
	}

	public Map<Integer, UserInfo> getList(List<Integer> idList)
	{
		Map<Integer, UserInfo> map = userInfoDao.getList(idList);
		return map;
	}
	
	public Page<UserInfo> list(UserInfo userInfo, Page<UserInfo> page)
	{
		page = userInfoDao.list(userInfo, page);
		return page;
	}
	
	public List<UserInfo> list(UserInfo userInfo)
	{
		List<UserInfo> list = userInfoDao.list(userInfo);
		return list;
	}

	public Page<OperatorLog> listLog(OperatorLog operatorLog, Page<OperatorLog> page)
	{
		page = operatorLogDao.list(operatorLog, page);
		return page;
	}
	
}
